package com.example.yls.materialdesign_3;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.BottomNavigationItem;

public class MainActivity extends AppCompatActivity {
    private BottomNavigationBar bottomNavigationBar;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                initBottomNavigationBar();
            }
        });
    }
    private void initBottomNavigationBar(){
        bottomNavigationBar=findViewById(R.id.id_bnb);
        bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.night,"A")
        .setActiveColor(Color.RED));
        bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.night,"B")
                .setActiveColor(Color.GREEN));
        bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.night,"C")
                .setActiveColor(Color.BLUE));
        bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.night,"D")
                .setActiveColor(Color.YELLOW));
        bottomNavigationBar.initialise();

        bottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.SimpleOnTabSelectedListener(){
            @Override
            public void onTabSelected(int position) {
                super.onTabSelected(position);
                switch (position){
                    case 0:
                        Toast.makeText(MainActivity.this,"A",Toast.LENGTH_SHORT).show();
                        break;
                    case 1:
                        Toast.makeText(MainActivity.this,"B",Toast.LENGTH_SHORT).show();
                        break;
                    case 2:
                        Toast.makeText(MainActivity.this,"C",Toast.LENGTH_SHORT).show();
                        break;
                    case 3:
                        Toast.makeText(MainActivity.this,"D",Toast.LENGTH_SHORT).show();
                        break;
                }
            }

            @Override
            public void onTabReselected(int position) {
                super.onTabReselected(position);
            }

            @Override
            public void onTabUnselected(int position) {
                super.onTabUnselected(position);
            }
        });
    }
}
